package com.jtstest.demo.utils;

import org.locationtech.jts.geom.*;

/**
 * @Description:
 * @author: fengyuhao
 * @date: 2021/3/14$ 19:15$
 */
public class JtsUtil {

    /**
     * srid为4326
     */
    public static final GeometryFactory geometryFactory4326 = new GeometryFactory(new PrecisionModel(), 4326);

    public static Point newPoint(double x, double y) {
        return geometryFactory4326.createPoint(new CoordinateXY(x, y));
    }
    public static LineString newLineString(Point[] points) {
        int length = points.length;
        CoordinateXY[] coordinate = new CoordinateXY[length];
        for(int i = 0; i < length; i ++){
            coordinate[i] = new CoordinateXY(points[i].getX(), points[i].getY());
        }
        return geometryFactory4326.createLineString(coordinate);
    }
}